﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace Kugar.Core.Communications.Transfer
{

    public class RUDPDataReceivedEventArgs : EventArgs
    {
        public RUDPDataReceivedEventArgs(byte[] data, int offset, int count)
        {
            Data = data;
            Offset = offset;
            Count = count;
        }

        public int ConnectID;
        public byte[] Data;
        public int Offset;
        public int Count;
    }

    public class RUDPConnectRequestEventArgs : EventArgs
    {
        public RUDPConnectRequestEventArgs(IPEndPoint remotePoint)
        {
            RemotePoint = remotePoint;
            Cancel = false;
        }

        public IPEndPoint RemotePoint { private set; get; }

        public bool Cancel { set; get; }
    }

    public class RUDPConnectSuccessEventArgs : EventArgs
    {
        internal RUDPConnectSuccessEventArgs(RUDPConnectionInternal connection)
        {
            Connection = connection;
        }

        public INetTransfer Connection { private set; get; }
    }

    public class RUDPDisconnectedEventArgs : EventArgs
    {
        private Exception _error;
        private RUDPConnectionInternal _connection;

        internal RUDPDisconnectedEventArgs(RUDPConnectionInternal connection, Exception error = null)
        {
            _connection = connection;
            _error = error;
        }

        public INetTransfer Connection { get { return _connection; } }

        public Exception Error { get { return _error; } }

        public bool HasError { get { return _error != null; } }

        internal int ConnectID { get { return _connection.ConnectID; } }
    }

}
